The present invention relates to monitoring memory accesses for computer programs. More specifically, the invention relates to multiple processes of a computer program monitoring memory accesses to a shared memory region.
Debugging is probably the most time intensive part of software development. There are many different types of programming bugs that can be manifested in the computer code. A common bug is a memory access bug, which in general is an access (e.g., read or write) to memory that should not be occurring. A simple example of a memory access bug is as follows. A region of available memory is requested and a pointer to that memory region is obtained. Subsequently, the memory region is freed or released, meaning that the program no longer requires the memory region. If the program latter accesses the memory region through the stale pointer, the results can be unpredictable and crashes can result.
Additional problems can occur if the memory is shared. In general, it is meant by “shared” memory that more than one process (of the same computer program or different computer programs) are able to allocate, utilize, and deallocate memory from the same area. As a result of the memory being shared, a process that writes data to a memory region utilizing a stale pointer can create unacceptable data for a different process that is currently utilizing the memory region. Thus, the other process can exhibit strange behavior or crash.
Debugging these kinds of errors can be extremely frustrating and time consuming. Setting watchpoints for the memory region that is suspect has the drawback that execution of the computer program halts every time the memory region is accessed. Extreme patience may be required if the erroneous memory access occurs after the memory region has been accessed a significant number of times. Often times, the setting of the watchpoint results in the erroneous memory access never occurring as a result of timing.
Typically, there many processes executing concurrently on modern computers. Conventional debuggers allow developers set watchpoints as described above. However, the watchpoints can drastically interrupt the flow of execution of the processes. As a result, the delays that are introduced in order to debug the computer program can result in the bugs never occurring. The timing can also be impacted by the overhead that is required to execute the debugger.
Solutions to this problem have met with limited success. For example, developers can look at the bit patterns of the corrupted memory in order to make an intelligent guess as to the section of computer code that is causing the problem. As can be imagined, this requires a significant amount of time and great knowledge of the computer code. As another example, there are special libraries that can be utilized in order to catch memory access violations. However, not all computer programs can utilize these libraries and the utilization of foreign libraries can generate a new source of errors.
It would be beneficial to have improved techniques for monitoring memory accesses for computer programs. Additionally, it would be beneficial to have innovative techniques for multiple processes to monitor memory accesses to a shared memory region.